<?php
/**
 * 页面定义
 */

class Base_Func
{
    function __get($name)
    {
        if ($name === 'one')
        {
            return $this->data_one;
        }
        else if ($name === 'split')
        {
            return $this->data_split;
        }
        else if ($this->isMyObj($name))
        {
            $className = $this->getClassName($name);
            $this->$name = new $className;
            return $this->$name;
        }
        return NULL;
    }

    private function isMyObj($name)
    {
        //目录
        $name = strtolower($name);
        $arr = explode('_', $name);
        if(empty($arr))
        {
            return false;
        }
        $dir = $arr[0];

        //文件
        $className = implode('_', array_map('ucfirst',$arr));
        $classFile = INCLUDE_PATH . $dir . DS . $className . '.php';
        if (is_file($classFile))
        {
            return true;
        }
        return false;
    }

    private function getClassName($name)
    {
        //目录
        $name = strtolower($name);
        $arr = explode('_', $name);
        if(empty($arr))
        {
            return false;
        }

        //文件
        $className = implode('_', array_map('ucfirst',$arr));
        return $className;
    }
}
?>